<template>
  <li @mouseenter="isShow = true" @mouseleave="isShow = false" :style = "{background: isShow ? 'skyblue' : ''}">
    <label>
      <input type="checkbox" :checked="done" @change="changeItemDone(id)"/><!-- 使用change事件，且要传值 -->
      <span>{{content}}</span>
    </label>
    <button class="btn btn-danger" :style="{display: isShow ? 'block' : 'none'}" @click="deleteOne(id)">删除</button>
  </li>
</template>

<script>
export default {
  name: "Item",
  props: ["id", "done", "content","changeItemDone",'deleteOne'],
  data() {
    return {
      isShow: false //遇见是否隐藏，要想到用变量的true，false，采用三元表达式，选择性获取我们想要的值
    }
  }
};
</script>

<style>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  display: none;
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}
</style>
